﻿using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Simple.Repository.Models.ClassRoom;
using Simple.Services.System.FileInfo.Models;
using Simple.Services.System.Recipes.Models;

namespace Simple.Services;

public class InspectionRecordQueryModel : PageInputModel
{
    /// <summary>
    /// 教室Id
    /// </summary>
    public Guid? GardenHouseClassRoomId { get; set; }


    public DateTime? StartTime { get; set; }

    public DateTime? EndTime { get; set; }
}

public class InspectionRecordPageViewModel : ModelBase
{
    public Guid Id { get; set; }
    /// <summary>
    /// 教室Id
    /// </summary>
    public Guid GardenHouseClassRoomId { get; set; }

    /// <summary>
    /// 教室名称
    /// </summary>
    public string ClassRoomName { get; set; }

    /// <summary>
    /// 巡检时间
    /// </summary>
    public DateTime CreatedTime { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public Guid? ResponsiblePerson { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public string ResponsiblePersonStr { get; set; }

    /// <summary>
    /// 巡检人
    /// </summary>
    public Guid? InspectionPerson { get; set; }

    /// <summary>
    /// 巡检人
    /// </summary>
    public string InspectionPersonStr { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public int RiskLevel { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public string RiskLevelStr { get; set; }

    public override void ConfigureMapper(Profile profile)
    {
        profile.CreateMap<InspectionRecord, InspectionRecordPageViewModel>();

        profile.CreateMap<InspectionRecordPageViewModel, InspectionRecord>();

        profile.CreateMap<InspectionRecord, InspectionRecordPageViewModel>()
           .ForMember(c => c.ClassRoomName, option => option.MapFrom(p => p.GardenHouseClassRoom.CRoomName));

    }
}

public class InspectionViewModel : ModelBase
{
    /// <summary>
    /// 教室Id
    /// </summary>
    public Guid GardenHouseClassRoomId { get; set; }

    /// <summary>
    /// 教室名称
    /// </summary>
    public string ClassRoomName { get; set; }


    /// <summary>
    /// 风险编号
    /// </summary>
    public string RiskNumber { get; set; }

    /// <summary>
    /// 风险源名称
    /// </summary>
    public string RiskSourceName { get; set; }

    /// <summary>
    /// 风险因素
    /// </summary>
    public string RiskFactors { get; set; }

    /// <summary>
    /// 风险类别
    /// </summary>
    public string RiskCategory { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public int RiskLevel { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public string RiskLevelStr { get; set; }

    /// <summary>
    /// 可能导致的事故及后果
    /// </summary>
    public string PossibleAccidents { get; set; }

    /// <summary>
    /// 现场照片
    /// </summary>
    public List<FileInfoModel> ImageList { get; set; }

    /// <summary>
    /// 管控依据
    /// </summary>
    public string? ControlBasis { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public Guid? ResponsiblePerson { get; set; }

    /// <summary>
    /// 巡检人
    /// </summary>
    public Guid? InspectionPerson { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public string? ResponsiblePersonStr { get; set; }

    /// <summary>
    /// 巡检人
    /// </summary>
    public string? InspectionPersonStr { get; set; }

    /// <summary>
    /// 巡检时间
    /// </summary>
    public virtual DateTime? CreatedTime { get; set; }



    public override void ConfigureMapper(Profile profile)
    {
        profile.CreateMap<InspectionRecord, InspectionViewModel>();

        profile.CreateMap<InspectionViewModel, InspectionRecord>();

        profile.CreateMap<InspectionRecord, InspectionViewModel>()
           .ForMember(c => c.ClassRoomName, option => option.MapFrom(p => p.GardenHouseClassRoom.CRoomName));

    }
}

public class ResponsibleDto
{

    public Guid? ResponsiblePerson { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public string? ResponsiblePersonStr { get; set; }

    /// <summary>
    /// 教室Id
    /// </summary>
    public Guid GardenHouseClassRoomId { get; set; }

    /// <summary>
    /// 教室名称
    /// </summary>
    public string ClassRoomName { get; set; }



}

public class AppViewModel
{
    /// <summary>
    /// 巡检Id
    /// </summary>
    public Guid? Id { get; set; }


    /// <summary>
    /// 教室名称
    /// </summary>
    public string ClassRoomName { get; set; }

    /// <summary>
    /// 巡检时间
    /// </summary>
    public virtual DateTime? CreatedTime { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public string RiskLevelStr { get; set; }


}



public class InspectionRecordDto
{
    public Guid? Id { get; set; }

    /// <summary>
    /// 教室Id
    /// </summary>
    public Guid GardenHouseClassRoomId { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public Guid? ResponsiblePerson { get; set; }

    /// <summary>
    /// 风险编号
    /// </summary>
    public string? RiskNumber { get; set; }

    /// <summary>
    /// 风险源名称
    /// </summary>
    public string? RiskSourceName { get; set; }

    /// <summary>
    /// 风险因素
    /// </summary>
    public string? RiskFactors { get; set; }

    /// <summary>
    /// 风险类别
    /// </summary>
    public string? RiskCategory { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public int RiskLevel { get; set; }

    /// <summary>
    /// 可能导致的事故及后果
    /// </summary>
    public string? PossibleAccidents { get; set; }

    /// <summary>
    /// 现场照片文件表单
    /// </summary>
    public List<IFormFile>? ImageList { get; set; }

    /// <summary>
    /// 现场图片文件Id
    /// </summary>
    public List<string> FileIds{ get; set; }

    /// <summary>
    /// 管控依据
    /// </summary>
    public string? ControlBasis { get; set; }

    public List<string> RemoveImageIds { get; set; }

}






public class InspectionRecordAddDto
{
    public Guid? Id { get; set; }

    /// <summary>
    /// 教室Id
    /// </summary>
    public Guid GardenHouseClassRoomId { get; set; }

    /// <summary>
    /// 责任人
    /// </summary>
    public Guid? ResponsiblePerson { get; set; }

    /// <summary>
    /// 风险编号
    /// </summary>
    public string? RiskNumber { get; set; }

    /// <summary>
    /// 风险源名称
    /// </summary>
    public string? RiskSourceName { get; set; }

    /// <summary>
    /// 风险因素
    /// </summary>
    public string? RiskFactors { get; set; }

    /// <summary>
    /// 风险类别
    /// </summary>
    public string? RiskCategory { get; set; }

    /// <summary>
    /// 风险等级
    /// </summary>
    public int RiskLevel { get; set; }

    /// <summary>
    /// 可能导致的事故及后果
    /// </summary>
    public string? PossibleAccidents { get; set; }

    /// <summary>
    /// 现场图片文件Id
    /// </summary>
    public List<string> FileIds { get; set; }

    /// <summary>
    /// 管控依据
    /// </summary>
    public string? ControlBasis { get; set; }
     

}
